'''
Created on 10 Sep 2009

@author: jack
'''
def MathViewer(shape_list,name):

    f=open(name+'.nb', 'w')
    f.write('SetDirectory[NotebookDirectory[]]')
    f.write('Export["'+name+'.pdf",Show[')
    for i in range(0,len(shape_list)):
        f.write('Graphics[Polygon[{');
        for j in range(0,3):
            f.write('{'+str(shape_list[i].coords[j][0])+','+str(-shape_list[i].coords[j][1])+'},')
        f.write('{'+str(shape_list[i].coords[3][0])+','+str(-shape_list[i].coords[3][1])+'}')
        if i<len(shape_list)-1:
            f.write('}]],')
        else:
            f.write('}]],ImageSize->2400')
    f.write(']]')
    f.close()